#!/bin/sh

if [ $# -lt 1 ]; then
    exit 0
fi

arg=$(readlink -f "$1")
#echo ${arg}
file=$(basename "$1")
#echo ${file}

case ${file} in
    *png*|*jpg*|*jpeg*)   (feh "${arg}" &) ;;
    *pdf*|*epub*|*djvu*)  (mupdf "${arg}" &) ;;
    *html*)               (surf "${arg}" &) ;;
    *torrent*)            (qbittorrent "${arg}" &) ;;
    *m3u*)                (cmus "${arg}" &) ;;
    *mkv*|*mp4*)          (mpv "${arg}" &) ;;
    *docx*|*odf*)         (libreoffice "${arg}" &) ;;
    *sc*)                 (st scim "${arg}" &) ;;
    *)                    (st vis "${arg}" &)
esac > /dev/null 2>&1
